﻿<UserControl x:Class="Mengsk.ProxyDelivery.App.UI.Goods.GiftUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" Loaded="UserControl_Loaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <Button Name="btnSearch" Content="查询" Margin="3" VerticalAlignment="Center" Width="60" Click="btnSearch_Click"/>
            <Button Name="btnAdd" Content="添加" Margin="3" VerticalAlignment="Center" Width="60" Click="btnAdd_Click"/>
        </StackPanel>

        <ListBox Grid.Row="1" Name="lstGift" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" >
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Grid Margin="5">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    
                                    <TextBlock Grid.Row="0" Text="{Binding Name}" Margin="3" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                    <Image Grid.Row="1" Width="100" Height="100" Source="{Binding Image,Converter={StaticResource webUrlImageConverter}}" />
                                    <StackPanel Grid.Row="2" Margin="3" Orientation="Horizontal" HorizontalAlignment="Center">
                                        <TextBlock Text="{Binding Price}" Margin="3" VerticalAlignment="Center"/>
                                        <TextBlock Text="/" Margin="3" VerticalAlignment="Center"/>
                                        <TextBlock Text="{Binding BuyInPrice}" Margin="3" VerticalAlignment="Center"/>
                                    </StackPanel>
                                    <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center">
                                        <Button Name="btnEdit" Content="编辑" Margin="3" VerticalAlignment="Center" DataContext="{Binding}" Click="btnEdit_Click"/>
                                        <Button Name="btnDelete" Content="删除" Margin="3" VerticalAlignment="Center" DataContext="{Binding}" Click="btnDelete_Click"/>
                                    </StackPanel>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
        
    </Grid>
</UserControl>
